package com.imay.live.activity.video;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.v7.widget.LinearLayoutManager;
import android.widget.LinearLayout;

import com.imay.live.view.AutoAdjustRecylerView;
import com.imay.live.R;

import java.util.ArrayList;

/**
 * Created by chan on 2017/6/7 0007.
 */

public class FilterHelper {

    private static FilterHelper instance;


    private ArrayList<Filter> filters = new ArrayList<>();

    public static FilterHelper getInstance() {
        if (instance == null) {
            instance = new FilterHelper();
        }
        return instance;
    }

    public void initFilter(Context context) {
        if (filters.isEmpty()) {
            getFilters(context);
        }
    }

    private void getFilters(Context context) {
        filters.add(new Filter(context.getString(R.string.fitter_orginal), -1));
        filters.add(new Filter(context.getString(R.string.fitter_fennen), R.mipmap.filter_fennen));
        filters.add(new Filter(context.getString(R.string.fitter_huaijiu), R.mipmap.filter_huaijiu));
        filters.add(new Filter(context.getString(R.string.fitter_landiao), R.mipmap.filter_landiao));
        filters.add(new Filter(context.getString(R.string.fitter_langman), R.mipmap.filter_langman));
        filters.add(new Filter(context.getString(R.string.fitter_qingliang), R.mipmap.filter_qingliang));
        filters.add(new Filter(context.getString(R.string.fitter_qingxin), R.mipmap.filter_qingxin));
        filters.add(new Filter(context.getString(R.string.fitter_rixi), R.mipmap.filter_rixi));
        filters.add(new Filter(context.getString(R.string.fitter_weimei), R.mipmap.filter_weimei));
    }

    public void initFilterDatas(AutoAdjustRecylerView recyclerView) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(recyclerView.getContext());
        linearLayoutManager.setOrientation(LinearLayout.HORIZONTAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setPxPerMillsec(1.0f);
        FilterAdapter mAdapter = new FilterAdapter(recyclerView.getContext(), recyclerView);
        recyclerView.setAdapter(mAdapter);
        mAdapter.setNames(filters);
    }

    public Filter getBitmap(int postion) {
       return filters.get(postion);
    }

    public class Filter {
        public int rid;
        public String fitterName;

        public Filter(String fitterName, int rid) {
            this.rid = rid;
            this.fitterName = fitterName;
        }
    }


}
